package com.jackstraw.jack_base.util.tenant.entity;

import com.jackstraw.jack_base.util.StringUtil;
import com.jackstraw.jack_base.util.entity.DefaultConstants;
import com.jackstraw.jack_base.util.tenant.entity.enums.TenantSchemaEnum;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Data
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class Tenant {

    @Value("${jack.tenantSchemaEnum:one}")
    private TenantSchemaEnum tenantSchemaEnum;


    @Value("${jack.defaultTenantName:}")
    private String defaultTenantName;

    public TenantSchemaEnum getTenantSchemaEnum() {
        return this.tenantSchemaEnum;
    }


    public String getDefaultTenantName() {
        if (StringUtil.StringUtilsBylang3.isEmpty(this.defaultTenantName)) {
            this.defaultTenantName = DefaultConstants.DEFAULT_TENANT_NAME;
        }
        return this.defaultTenantName;
    }


}
